<?php
namespace Phone\Controller;
use Think\Controller;
/**
* 
*/
class LoginController extends Controller{
	//查询快递
	public function index(){
		$this->display();
	}
	public function login(){
		$res=D("User")->where(array("name"=>I("post.name")))->find();
		if(!$res||$res['pass']!=md5(I("post.pass"))){
			$this->error("账号或密码错误!");
		}else{
			session("name",$res['name']);
			session("id",$res['id']);
			$openid = explode(',', $res['openid']);
			if(!in_array(session('openid'), $openid)){
				$openid[] = session('openid');
			}
			M("User")->where(array('id'=>$res['id']))->save(array('openid'=>implode(',',$openid)));
			$this->success();
		}
	}
	public function test(){
		redirect("http://meijiada.yunapply.com/Api/ApiList/openid");	
	}
	
	public function openid(){
		var_dump($_REQUEST);
	}
}